package com.cyandpos.pad.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.cyandpos.pad.R;
import com.cyandpos.pad.utils.CommonUtils;


public class ScanCodeActivity extends BaseActivity implements View.OnClickListener {
    private RelativeLayout rl_close;
    private EditText ed_cashbox_pw;
    private Button btn_opencashbox;
    @Override
    protected void initData() {
        rl_close=findViewById(R.id.rl_close);
        ed_cashbox_pw=findViewById(R.id.ed_cashbox_pw);
        CommonUtils.hideSoftInputButWithSelection(ed_cashbox_pw, ScanCodeActivity.this);
        btn_opencashbox=findViewById(R.id.btn_opencashbox);
        rl_close.setOnClickListener(this);
        btn_opencashbox.setOnClickListener(this);

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_scan;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.rl_close:
                finish();
                break;
            case R.id.btn_opencashbox:
                if("".equals(ed_cashbox_pw.getText()+"")){
                    Toast.makeText(this,"请扫码!",Toast.LENGTH_SHORT).show();
                }else {
                    Intent intent = new Intent();
                    Bundle bundle = new Bundle();
                    bundle.putString("Code", ed_cashbox_pw.getText() + "");
                    bundle.putInt("PayFlag", getIntent().getIntExtra("Type", 0));
                    intent.putExtras(bundle);
                    setResult(RESULT_OK, intent);
                    ScanCodeActivity.this.finish();
                }
                break;
        }

    }
}
